package com.example.springsecuritydemo;

class Xc implements Runnable {

    public static int chepiao = 100;

    public void run() {
        while (true) {
            if (chepiao > 0) {
                System.out.println("第" + Thread.currentThread().getName() + "个车站正在卖出第" + (101 - chepiao) + "张车票");
                chepiao--;
                System.out.println(chepiao);
            } else {
                break;
            }
        }
    }
}

public class XianCheng {
    public static void main(String[] args) {
        Thread Xc1 = new Thread(new Xc());//模拟两个车站在卖车票，竞争共同的线程资源
        Xc1.start();
        Thread Xc2 = new Thread(new Xc());//模拟两个车站在卖车票，竞争共同的线程资源
        Xc2.start();


    }
}
